package com.lysj.bhp.withdraw.repository;


import com.lysj.bhp.withdraw.domain.WithDraw;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;


public interface WithdrawRepository extends JpaRepository<WithDraw, Long>, JpaSpecificationExecutor {

    List<WithDraw> findByStatus(int status);

    //    List<WithDraw> findByUserIdAndTypeOrTypeOrderByCreateDateDesc(Long userId, int type, int type2, Pageable pr);
    List<WithDraw> findByUserIdAndTypeInOrderByCreateDateDesc(Long userId, Integer[] typeIds, Pageable pr);

    // 查询bhpc提币记录
    @Query("from WithDraw w where w.userId=?1 and w.type in (?2,?3)")
    List<WithDraw> findBhpcWithdraw(Long userId, int type, int type2, Pageable pr);


    List<WithDraw> findByUserIdAndTypeOrderByCreateDateDesc(Long userId, int type, Pageable pr);

    List<WithDraw> findByUserIdOrderByCreateDateDesc(Long userId, Pageable pr);

    int countByUserIdAndType(Long userId, int type);

    /**
     * 查询提币申请，状态为0的
     */
    List<WithDraw> findByStatusOrderByCreateDateDesc(int status);


    List<WithDraw> findByUserIdAndTypeOrderByCreateDateDesc(Long userId, int type);


    List<WithDraw> findByUserId(Long userId);

    List<WithDraw> findByStatusAndOperationTypeOrderByCreateDateDesc(int status, int operationType);

    WithDraw findFirstByTransctionStatusOrderByLastQueryTimeAsc(int transctionStatus);

    //查询用户是否用未完成的提币
    int countByUserIdAndTypeAndCheckStatus(Long userId, int type, int checkStatus);

    //查询用户对应币种的提币数量
    List<WithDraw> findByUserIdAndTypeAndCheckStatusInAndCreateDateBetween(Long userId, int type,Integer[] checkStatus, Date beginDate, Date endDate);
}
